package com.wk.code.wkserver.controller.admin;


import com.wk.code.wkserver.controller.common.BaseController;
import com.wk.code.wkserver.entity.User;
import com.wk.code.wkserver.request.admin.TechUserVerifyRequest;
import com.wk.code.wkserver.request.app.UserRequest;
import com.wk.code.wkserver.response.admin.*;
import com.wk.code.wkserver.response.base.PageInfo;
import com.wk.code.wkserver.response.result.R;
import com.wk.code.wkserver.service.HomeStatisticsService;
import com.wk.code.wkserver.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制层
 *
 * @Author wq
 * @Date 2021-03-16
 **/
@RestController
@RequestMapping("admin/home")
@AllArgsConstructor
@Api(tags = "admin-后台首页统计管理")
public class AdminHomeController {

    private final HomeStatisticsService statisticsService;


    /**
     * 后台首页统计
     *
     * @return R
     */
    @ApiOperation(value = "后台首页统计")
    @GetMapping("/homeStatis")
    public R<AdminHomeResponse> homeStatistics() {
        return R.success(statisticsService.homeStatistics());
    }


    /**
     * 最近七天的图表
     *
     * @param type 1 注册量 2 访问量
     * @return List<AdminHomeChartResponse>
     */
    @ApiOperation(value = "后台首页图表统计")
    @GetMapping("/recentlyChart")
    public R<AdminHomeChartResponse> recentlyChart(Integer type) {
        return R.success(statisticsService.recentlyChart(type));
    }

    /**
     * 后台首页饼状图图表统计
     *
     * @return R
     */
    @ApiOperation(value = "后台首页饼状图图表统计")
    @GetMapping("/userRatio")
    public R<AdminUserRatioResponse> recentlyChart() {
        return R.success(statisticsService.userRatio());
    }

    /**
     * 后台交易统计图表统计
     *
     * @return R
     */
    @ApiOperation(value = "后台首页饼状图后台交易统计统计")
    @GetMapping("/tradeRatio")
    public R<AdminHomeMoneyResponse> tradeRatio() {
        return R.success(statisticsService.tradeRatio());
    }

}